package com.itheima.homework;

import java.util.Scanner;

/**
 * @Author 王加鑫
 * @Date 2021/4/22 18:50
 * @Version 1.0
 * 13、【编号：302】 需求：一年有12个月，分属于春夏秋冬4个季节，键盘录入一个月份，请用程序实现判断该月份属于哪个季节，并输出。
 *     春：3、4、5
 *     夏：6、7、8
 *     秋：9、10、11
 *     冬：1、2、12
 */
public class Day05HomeWork13 {
    public static void main(String[] args) {
        //键盘接收录入月份吧
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入月份:");
        //月份
        int month = scanner.nextInt();
        //一年12个月,用数组定义
        int[] year = {1,2,3,4,5,6,7,8,9,10,11,12};
        //输出季节
        String season = getMonth(month,year);
        System.out.println(season);

    }

    /*

     */
    public static String getMonth(int month,int[] year){
        //定义季节
        String season = "";
        //遍历数组
        if(month <= year[1] || month == year[year.length-1]){
            season = "冬季";
        }else if(month > year[2] && month <= year[4]){
            season = "春季";
        }else if(month > year[4] && month <= year[7]){
            season = "夏季";
        }else if(month > year[7] && month <= year[10]){
            season = "秋季";
        }
        return season;
    }
}
